package cn.tedu.store.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.tedu.store.bean.Area;
import cn.tedu.store.bean.City;
import cn.tedu.store.bean.Province;
import cn.tedu.store.bean.ResponseResult;
import cn.tedu.store.service.IDistrictService;

@Controller
@RequestMapping("/dict")
public class DistrictController extends BaseController{
	@Resource(name="districtService")
	private IDistrictService districtService;
	
	@RequestMapping(value="/provinces.do",method=RequestMethod.GET)
	@ResponseBody
	public ResponseResult<List<Province>> getProvinces(){
		ResponseResult<List<Province>> rr;
		List<Province> provinces=districtService.getProvinces();
		rr=new ResponseResult<List<Province>>(1,"获取省列表",provinces);
		return rr;
	}
	@RequestMapping(value="/cities.do",method=RequestMethod.GET)
	@ResponseBody
	public ResponseResult<List<City>> getCities(@RequestParam("parent") String parent){
		ResponseResult<List<City>> rr;
		List<City> cities=districtService.getCities(parent);
		rr=new ResponseResult<List<City>>(1,"获取市列表",cities);
		return rr;
	}
	@RequestMapping(value="/areaes.do", method=RequestMethod.GET)
	@ResponseBody
	public ResponseResult<List<Area>> getAreaes(@RequestParam("parent") String parent){
		ResponseResult<List<Area>> rr;
		List<Area> areaes=districtService.getAreaes(parent);
		rr=new ResponseResult<List<Area>>(1,"获取区县列表",areaes);
		return rr;
	}
	
}
